package com.edu.exam.entity.examination.paper.technical;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import com.edu.exam.enums.examination.paper.RecognitionStatus;

import jakarta.persistence.*;
import java.time.LocalDateTime;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

/**
 * 扫描识别结果实体类
 *
 * 根据E-04-01设备适配子模块数据库设计实现
 * 存储单个答题卡识别的完整结果数据。
 *
 * @author System
 * @version 1.0.0
 */

@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class ScanRecognitionResult {

    /**
     * 结果ID，主键
     */
    @Id
    @Column(name = "result_id", length = 64)
    private String resultId;

    /**
     * 任务ID
     */
    @Column(name = "task_id", length = 64, nullable = false)
    private String taskId;

    /**
     * 图片ID
     */
    @Column(name = "image_id", length = 64, nullable = false)
    private String imageId;

    /**
     * 考试ID
     */
    @Column(name = "exam_id", length = 64, nullable = false)
    private String examId;

    /**
     * 学生ID
     */
    @Column(name = "student_id", length = 64)
    private String studentId;

    /**
     * 班级ID
     */
    @Column(name = "class_id", length = 64)
    private String classId;

    /**
     * 扫描时间
     */
    @Column(name = "scan_time", nullable = false)
    private LocalDateTime scanTime;

    /**
     * 处理时间（毫秒）
     */
    @Column(name = "processing_time")
    private Long processingTime;

    /**
     * 总体质量分数
     */
    @Column(name = "overall_quality", precision = 5, scale = 2)
    private Double overallQuality;

    /**
     * 识别状态
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "recognition_status", length = 32, nullable = false)
    private RecognitionStatus recognitionStatus;

    /**
     * 错误信息
     */
    @Column(name = "error_message", columnDefinition = "TEXT")
    private String errorMessage;

    // ===== 标准审计字段 =====

    /**
     * 创建时间
     */
    @CreationTimestamp
    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    /**
     * 更新时间
     */
    @UpdateTimestamp
    @Column(name = "updated_time", nullable = false)
    private LocalDateTime updatedTime;

    /**
     * 版本号（乐观锁）
     */
    @Version
    @Column(name = "version", nullable = false)
    private Long version = 0L;

    /**
     * 是否删除
     */
    @Column(name = "is_deleted", nullable = false)
    private Boolean isDeleted = false;

}